/*global pi */

pi.mod.define('pi.browser', function (pi) {
	"use strict";

	var module = {},
		vcalls = [
			/*
			 * 创建浏览器
			 * url:　初始url
			 * return: 无意义(msg.wParam)
			 */
			// module.create (url)
			["CreateBrowser", pi.vcall.TYPE_INT, [pi.vcall.TYPE_STRING], "create"],

			// module.setCallback (webView, paintFunc, resizeFunc)
			["BrowserSetJsFunc", pi.vcall.TYPE_VOID, [pi.vcall.TYPE_POINTER, pi.vcall.TYPE_OBJECT, pi.vcall.TYPE_OBJECT], "setCallback"],
			
			// module.paint (webView, memHandle, width, height)
			["BrowserPaint", pi.vcall.TYPE_VOID, [pi.vcall.TYPE_POINTER, pi.vcall.TYPE_POINTER, pi.vcall.TYPE_INT, pi.vcall.TYPE_INT], "paint"],

			// module.isDirty (webView)
			["BrowserIsDirty", pi.vcall.TYPE_INT, [pi.vcall.TYPE_POINTER], "isDirty"],

			// module.resize (webView)
			["BrowserResize", pi.vcall.TYPE_INT, [pi.vcall.TYPE_POINTER], "resize"],
			
			["BrowserSetSize", pi.vcall.TYPE_VOID, [pi.vcall.TYPE_POINTER, pi.vcall.TYPE_INT, pi.vcall.TYPE_INT], "setSize"],
			
			/*
			 * module.invoke (handle(webview or browser), type, p1, p2): common invoke function
			 *
			 * type: 1, get browser handle from webView handle
			 * h: webView handle
			 *
			 * type: 2, set msg proc callback
			 * h: browser handle
			 */
			["BrowserInvokeCmd", pi.vcall.TYPE_OBJECT, [pi.vcall.TYPE_POINTER, pi.vcall.TYPE_INT, pi.vcall.TYPE_OBJECT, pi.vcall.TYPE_OBJECT], "invokeCmd"]
		];

	// 注册所有 vcall 函数句柄
	pi.vcall.makeVCall("wkeBrowser.dll", module, vcalls);

	// for invokeCmd
	module.TYPE_GET_BROWSER_HANDLE = 1;
	module.TYPE_SET_MSG_PROC = 2;
	
	return module;
});